package entity;

public class WServiceProxy implements entity.WService {
  private String _endpoint = null;
  private entity.WService wService = null;
  
  public WServiceProxy() {
    _initWServiceProxy();
  }
  
  public WServiceProxy(String endpoint) {
    _endpoint = endpoint;
    _initWServiceProxy();
  }
  
  private void _initWServiceProxy() {
    try {
      wService = (new entity.WServiceServiceLocator()).getWService();
      if (wService != null) {
        if (_endpoint != null)
          ((javax.xml.rpc.Stub)wService)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        else
          _endpoint = (String)((javax.xml.rpc.Stub)wService)._getProperty("javax.xml.rpc.service.endpoint.address");
      }
      
    }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  
  public String getEndpoint() {
    return _endpoint;
  }
  
  public void setEndpoint(String endpoint) {
    _endpoint = endpoint;
    if (wService != null)
      ((javax.xml.rpc.Stub)wService)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    
  }
  
  public entity.WService getWService() {
    if (wService == null)
      _initWServiceProxy();
    return wService;
  }
  
  public java.lang.String helloWorld() throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    return wService.helloWorld();
  }
  
  public entity.Produto[] getProdutos(java.lang.String control) throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    return wService.getProdutos(control);
  }
  
  public int iniciarVenda(entity.Funcionario umFuncionario, entity.Cliente umCliente) throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    return wService.iniciarVenda(umFuncionario, umCliente);
  }
  
  public void adicionarProduto(int idVenda, int idCliente) throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    wService.adicionarProduto(idVenda, idCliente);
  }
  
  public entity.Venda recuperarVenda(int idVenda) throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    return wService.recuperarVenda(idVenda);
  }
  
  public entity.Produto[] recuperarProdutosVenda(int idVenda) throws java.rmi.RemoteException{
    if (wService == null)
      _initWServiceProxy();
    return wService.recuperarProdutosVenda(idVenda);
  }
  
  
}